package org.railage.server.entities;

import java.io.Serializable;
import java.sql.Timestamp;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;

import org.hibernate.annotations.NamedNativeQuery;
import org.railage.common.dto.TicketOfUserDTO;

/**
 * TicketOfUser entity
 * 
 * @author Cyril Fertikov
 * 
 */
@NamedNativeQuery(
		name = "getTicketsOfUser", 
		query = "call proc_get_tickets_of_user(:userID)", 
		resultClass = TicketOfUser.class
)
@Entity
public class TicketOfUser implements Serializable {

	private static final long serialVersionUID = -8356484429155424873L;

	@Id
	@Column(name = "trip_id")
	private int tripID;

	@Column(name = "route_name")
	private String routeName;

	@Column(name = "departure_time")
	private Timestamp departureTime;

	@Column(name = "departure_station")
	private String departureStation;

	@Column(name = "arrival_time")
	private Timestamp arrivalTime;

	@Column(name = "arrival_station")
	private String arrivalStation;

	public int getTripID() {
		return tripID;
	}

	public void setTripID(int tripID) {
		this.tripID = tripID;
	}

	public String getRouteName() {
		return routeName;
	}

	public void setRouteName(String routeName) {
		this.routeName = routeName;
	}

	public Timestamp getDepartureTime() {
		return departureTime;
	}

	public void setDepartureTime(Timestamp departureTime) {
		this.departureTime = departureTime;
	}

	public String getDepartureStation() {
		return departureStation;
	}

	public void setDepartureStation(String departureStation) {
		this.departureStation = departureStation;
	}

	public Timestamp getArrivalTime() {
		return arrivalTime;
	}

	public void setArrivalTime(Timestamp arrivalTime) {
		this.arrivalTime = arrivalTime;
	}

	public String getArrivalStation() {
		return arrivalStation;
	}

	public void setArrivalStation(String arrivalStation) {
		this.arrivalStation = arrivalStation;
	}

	public TicketOfUserDTO toDTO() {
		TicketOfUserDTO dto = new TicketOfUserDTO();
		dto.setTripID(tripID);
		dto.setRouteName(routeName);
		dto.setDepartureTime(departureTime);
		dto.setDepartureStation(departureStation);
		dto.setArrivalTime(arrivalTime);
		dto.setArrivalStation(arrivalStation);
		return dto;
	}

}
